GBML manual / Events

hit_room_edge

Runs every frame this instance’s position is at or past the room’s boundary on some axis (a superset of Beyond Room - includes standing exactly on the edge).

Syntax

hit_room_edge: fires every frame this instance is at or past the room’s edge

Description

Runs every frame this instance's position is at or past the room's boundary on some axis - a superset of Beyond Room that also includes standing exactly on the edge, not only past it. Also a level check, not an edge trigger: it fires every frame the condition holds. An object that needs "just the one frame this happened" has to keep its own flag and compare against it.

Example

Telling "the frame it first happened" apart from "still happening" needs a flag - and a flag needs an instance variable, which means declaring it in Create first (see Variables, types and scope):

at_edge_before = false;

Then, in Hit Room Edge itself:

if (!at_edge_before) {
    hsp = -hsp;
}
at_edge_before = true;

Bounces this instance's own horizontal speed only on the frame it first reaches the edge - the flag at_edge_before (declared above, in Create) is what tells that frame apart from every frame afterward it is still touching it.

On the GBA

A LEVEL check, not edge-triggered: it fires every frame the condition holds, not just once on the crossing frame - an object that wants "just the one frame it happened" needs its own "was I already past it" flag.

See also: beyond_roombeyond_viewEvents